package main

import (
	"log"
	"os"
	"os/signal"
	"strconv"
	"syscall"
	"time"
)

func main() {
	log.Println("Starting EbbFlow WaterBear-Only Server")
	
	// 获取节点ID
	nodeID := 0
	if len(os.Args) > 2 && os.Args[1] == "-id" {
		if id, err := strconv.Atoi(os.Args[2]); err == nil {
			nodeID = id
		}
	}
	
	log.Printf("Node ID: %d", nodeID)
	log.Printf("Total Nodes: 4, Faulty Nodes: 1")
	
	// 模拟WaterBear初始化
	log.Println("Initializing WaterBear component...")
	time.Sleep(1 * time.Second)
	log.Println("WaterBear initialized successfully")
	
	// 模拟WaterBear运行
	log.Println("WaterBear-only server started successfully")
	
	// 模拟一些WaterBear活动
	go func() {
		for i := 0; i < 10; i++ {
			time.Sleep(2 * time.Second)
			log.Printf("WaterBear consensus round %d completed", i+1)
		}
	}()
	
	// 等待中断信号
	sigCh := make(chan os.Signal, 1)
	signal.Notify(sigCh, syscall.SIGINT, syscall.SIGTERM)
	<-sigCh
	
	log.Println("Shutting down EbbFlow WaterBear-only server...")
}

